package com.example.administrator.stargo.utils;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

/**
 * Created by Mloong on 2017/11/29.
 */

public class MyDialog extends Dialog {
    //    style引用style样式
    public MyDialog(Context context, int width, int height, View layout, int style) {

        super(context, style);

        setContentView(layout);

        WindowManager wm = (WindowManager) getContext()
                .getSystemService(Context.WINDOW_SERVICE);

        int widths = wm.getDefaultDisplay().getWidth();

        Window window = getWindow();

        WindowManager.LayoutParams params = window.getAttributes();

        params.width = (int)(widths * 0.9);

        window.setAttributes(params);
    }
}
